﻿Imports System.Web.Security
Imports System.Data
Imports System.Data.SqlClient
Partial Class deluser
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = ""
        If Seperate(Session("admin"), "username") <> TextBox2.Text Then
            If addUser1() Then Label1.Text = "User da duoc xoa ra khoi csdl"
        End If
    End Sub
    Private Function addUser1() As Boolean
        On Error GoTo hErr
        Dim sSql As String
        ' Insert into
        sSql = " delete admin where username=@username and hoten=@hoten"
        Dim myConn As New SqlConnection(ConfigurationManager.AppSettings("cons"))
        Dim MyCommand As SqlCommand
        myConn.Open()
        MyCommand = New SqlCommand(sSql, myConn)
        MyCommand.Parameters.Add(New SqlParameter("@hoten", Replace(TextBox1.Text, "'", "''")))
        MyCommand.Parameters.Add(New SqlParameter("@username", Replace(TextBox2.Text, "'", "''")))
        MyCommand.ExecuteNonQuery()
        myConn.Close()
        Return True
        Exit Function
hErr:
        Return False
    End Function
    

End Class
